package tech.dx.springdb.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tech.dx.springdb.entity.ClassRecords;
import tech.dx.springdb.respository.ClassRecordsRepository;
import tech.dx.springdb.service.ClassRecordsService;

import java.util.Optional;

/**
 * @ClassName ClassRecordsServiceImpl
 * @Description TODO
 * @Author daoxuan
 * @Date 2019/4/1 12:20
 * @Version 1.0
 */
@Service
public class ClassRecordsServiceImpl implements ClassRecordsService {
    @Autowired
    private ClassRecordsRepository classRecordsRepository;

    @Override
    public ClassRecords add(ClassRecords classRecords) {
        ClassRecords save = classRecordsRepository.save(classRecords);
        return save;
    }

    @Override
    public Optional<ClassRecords> getById(long id) {
        return classRecordsRepository.findById(id);
    }

    @Override
    public ClassRecords update(ClassRecords classRecords) {
        return classRecordsRepository.save(classRecords);
    }

    @Override
    public void del(long id) {
        classRecordsRepository.deleteById(id);
    }
}
